
public class PreminumCaculator {
    public double insurancePoint(int age, String sex, String marraidStatus, int child){
        int a;
        int s;
        int m;
        double c;
        double point;
        if(age >= 20 && age <= 39){
            a = 6;
        }else if (age >= 40 && age <= 59){
            a = 4;
        }else if (age >= 0 && age <= 150){
            a = 2;
        }else {
            a = -1;
        }
        if ("m".equalsIgnoreCase(sex)){
            s = 4;
        }else if ("f".equalsIgnoreCase(sex)){
            s = 3;
        }else {
            s = -1;
        }
        if ("已婚".equals(marraidStatus)){
            m = 3;
        }else if ("未婚".equals(marraidStatus)){
            m = 5;
        }else {
            m = -1;
        }
        if (child >= 0) {
            c = child * 0.5;
            if (c > 3) {
                c = 3;
            }
        }else {
            c = -1;
        }
        point = a + s + m - c;
        if(a == -1 || s == -1 || m == -1 || c == -1){
            throw new PreminumException("参数错误");
        }
        return point;
    }
}
